# for i in range(1, 10):
#     #print(i)
#     for j in range(1, i + 1):#j的最大循环次数由i限制
#         # print(j) j一直是1
#         #print(i + 1)
#         print(f'{i}*{j}={i*j}', end=' ')#end默认换行结尾
#
#     print()#默认end换行，通过并列区分是谁的子函数

# n = 1
# while n <= 9:
#     m = 1
#     while m <= n:
#         print(f'{n}*{m}={n*m}', end=' ')
#         m = m + 1
#     n = n + 1
#     print()#m与n同时充当了两种作用，一种是循环次数，一种乘法表中的数值
# while True: #while true是永远循环
#     s = input('输入: (0) 退出: ')
#     if s == '0':
#         break
#     print('你输入的是:', s)

# for s in 'python':#可以虚幻字符串
#     if s == 'y':
#         continue
#     print(s)

# for n in [1, 2, 3, 4, 5, 6]:#可以循环数组
#     if n == 3:
#         continue
#     print(n)


# import random
# m = random.randint(1, 100)
# while True:
#     n = int(input('输入1~100:'))
#     if n < m:
#         print('猜小了')
#     elif n > m:
#         print('da')
#     else:
#         print('猜对了')

# import sys
# from PIL import Image, ImageDraw, ImageFont
# image = Image.open("C:/Users/nmsl/Pictures/Camera Roll/1.jpg")
# #print(image.format, image.mode)
# #image.show()
# image_copy = image.copy()#复制zhu图
# image_new = Image.new('RGB', (160, 90), (0, 0, 255))#蓝图
# #print(image_new.format, image_new.mode)
# #image_new.show()
# image_new2 = Image.new('L', (160, 90), '#646464')#灰图
# #image_new2.show()
# image_copy.paste((0, 0, 255), (100, 100, 260, 190), mask=image_new2)#mode不匹配会转化, image_new是被 paste ，image可以是元组
# #蒙版，传入一张与被粘贴图片尺寸一样的图片，一个灰色的蒙版，融合了，没有那么蓝了
# image_copy.save('zhu.jpg')#改图片名字
# image_save = Image.open("zhu.jpg")#改图片变量
# #print(image_save.format, image_save.mode)
# #image_copy.show()#经过改造的image_copy
# #image_save.show()#连变量名字都改了

# image_bg = Image.new('RGB', (2480, 3508), (255, 255, 255))
# #image_bg.show()
# draw = ImageDraw.Draw(image_bg)#创建 'image_bg' 对象可以绘图
# draw.line((0, 0) + image_bg.size, fill=128, width=5)
# draw.line((0, image_bg.size[1], image_bg.size[0], 0), fill=128)
# draw.line((0, image_bg.size[1]/2) + (image_bg.size[0]/2, image_bg.size[1]), fill=128, width=5)
# image_bg.show()

# base = image_bg.convert('RGBA')
# txt = Image.new('RGBA', base.size, (55, 55, 55, 0))
# fnt = ImageFont.truetype('cambriai.ttf', 40)
# d = ImageDraw.Draw(txt)
# d.text((10, 10), "Hello", font=fnt, fill=(255, 255, 255, 128))
# d.text((10,60), "World", font=fnt, fill=(255, 255, 255, 255))
# fillcolor = "#ff0000"
# d.text((base.size[0]-20, 10), "4", font=fnt, fill=fillcolor)
# out = Image.alpha_composite(base, txt)
# out.show()


# if __name__ == '__main__':#好像有用
#     from tkinter import *#tm的竟然是小写
#
#     root = Tk()#tm的竟然是大写，应该是创建一个tk对象
#     root.title('canvas')
#     canvas = Canvas(root, width=3508, height=2480, bg='blue')
#     x0 = 100#左边距
#     y0 = 100#右边距
#     y1 = 75#最开始方框的大小
#     x1 = 75
#     for i in range(10):
#         canvas.create_rectangle(x0, y0, x1, y1)
#         x0 -= 5
#         y0 -= 5
#         x1 += 5
#         y1 += 5
#
#     #canvas.pack()
#     root.mainloop()#这是弹窗,对象弹窗




from PIL import Image, ImageDraw, ImageFont
bg = Image.new('RGB', (2480, 3580), (255, 255, 255))
draw = ImageDraw.Draw(bg)
#print(bg.size)
draw.line((80, 80) + (2000, 80), fill=(0, 155, 0), width=5)#两个元组相加() + (),起点到终点
draw.line((80, 80) + (80, 3000), fill=(0, 155, 0), width=5)
x0 = 80
y0 = 80
x1 = 2000
y1 = 80
for i in range(30):
    draw.line((x0, y0) + (x1, y1), fill=(0, 155, 0), width=1)#循环此函数
    y0 += 100
    y1 += 100
    if i == 28:
        draw.line((x0, y0) + (x1, y1), fill=(0, 155, 0), width=5)# if里面不知道为啥数字不能用
x0 = 80# 变量不能公用？x0还要重新声明？
y0 = 80
x2 = 80
y2 = 3000
for i in range(20):
    draw.line((x0, y0) + (x2, y2), fill=(0, 155, 0), width=1)
    x0 += 100
    x2 += 100
    if i == 18:
        draw.line((x0, y0) + (x2, y2), fill=(0, 155, 0), width=5)
path_to_ttf = r'c:\windows\fonts\msyh.ttc'
typeface = ImageFont.truetype(path_to_ttf, 100)# 创建字体
tempwords = '编程从入门到入土\n编程从入门到入土'
twice = tempwords.split('\n')
words = tempwords.split('\n')[0]
#print(len(words))
#print(len(words[1]))
# if isinstance(words, str):#是字符串
#     print("is str")
# else:
#     print(" is not str")
x3, y3 = 120, 115
for i in range(0, len(twice)):
    #print(i)#还是没执行
    x3 = 120#调整第二行x的初始位置
    for a in range(0, len(words)):
        #print(len(words[a]))#压根就没执行
        #print(a)
        draw.text((x3, y3), words[a], font=typeface, fill=(0, 0, 0))# draw对象上写字
        print(x3)
        x3 += 200
    y3 += 200

# print(bg.mode)
# bg.save("bg.png")#save会把图片保存在同一个目录下
bg.show()

# from tkinter import *
#
# root = Tk()
# root.title('rectangle')
# canvas = Canvas(root, width=500, height=500, bg='yellow')
# canvas.pack()
#
# x0, y0, x1, y1 = 200, 200, 300, 300
#
# canvas.create_rectangle(x0, y0, x1, y1,  width=1)
#
#
# mainloop()
# rectangle改不了颜色

# from PIL import Image, ImageDraw, ImageFont
#
# # get an image
# base = Image.open('zhu.jpg').convert('RGBA')#为什么要转化RGBA,转化图片，composite要用
# print(base.size)
# txt = Image.new('RGBA', base.size, (255, 255, 255, 0))#创建个背景有啥用,变量base.size大小
# #txt.show()灰图
# fnt = ImageFont.truetype('cambriai.ttf', 40)#对象字体
# d = ImageDraw.Draw(txt)#可以画的空数据对象
# # draw text, half opacity
# d.text((10, 10), "Hello", font=fnt, fill=(255, 255, 255, 128))#写字函数text,128是透明度
# # draw text, full opacity
# d.text((10, 60), "World", font=fnt, fill=(255, 255, 255, 255))#(x, y)
# fillcolor = "#ff0000"  # 数据颜色
# d.text((base.size[0] - 20, 10), "4", font=fnt, fill=fillcolor)#元组(300, 300)减20
# out = Image.alpha_composite(base, txt)#合成base图片和灰图
# #out.show()














